<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>papyros.Master</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="papyros-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Papyros API documentation</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="papyros-module.html">Package&nbsp;papyros</a> ::
        Class&nbsp;Master
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="papyros.Master-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Master</h1><span class="codelink"><a href="papyros-pysrc.html#Master">source&nbsp;code</a></span><br /><br />
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">Master</strong>
</pre>

<dl><dt>Known Subclasses:</dt>
<dd>
    <a href="papyros.multithreaded.MultiThreadedMaster-class.html">multithreaded.MultiThreadedMaster</a>,
    <a href="papyros.distributed.DistributedMaster-class.html">distributed.DistributedMaster</a>,
    <a href="papyros.singlethreaded.SingleThreadedMaster-class.html">singlethreaded.SingleThreadedMaster</a>
</dd></dl>

<hr />
A <a href="papyros.Job-class.html" class="link">Job</a> dispatcher 
  object, controlling a set of <a href="papyros.Slave-class.html" 
  class="link">slaves</a>.<br /><br />

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">input_size</span>=<span class="summary-sig-default">0</span>,
        <span class="summary-sig-arg">output_size</span>=<span class="summary-sig-default">0</span>)</span><br />
      Initialize this master.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#addJob" class="summary-sig-name">addJob</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">job</span>,
        <span class="summary-sig-arg">timeout</span>=<span class="summary-sig-default">None</span>)</span><br />
      Add a <a href="papyros.Job-class.html" class="link">Job</a> to the
      input queue.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.addJob">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="cancelAllJobs"></a><span class="summary-sig-name">cancelAllJobs</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Cancel all unassigned jobs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.cancelAllJobs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="numPendingJobs"></a><span class="summary-sig-name">numPendingJobs</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Return the approximate number of pending (waiting or in progress) 
      jobs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.numPendingJobs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#popProcessedJob" class="summary-sig-name">popProcessedJob</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">timeout</span>=<span class="summary-sig-default">None</span>)</span><br />
      Pop the next processed <a href="papyros.Job-class.html" 
      class="link">Job</a> from the output queue.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.popProcessedJob">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#processedJobs" class="summary-sig-name">processedJobs</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">timeout</span>=<span class="summary-sig-default">None</span>)</span><br />
      Return a list of processed jobs.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master.processedJobs">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#_assignJob" class="summary-sig-name">_assignJob</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">poll_time</span>=<span class="summary-sig-default">10</span>)</span><br />
      Pop the next unassigned non-cancelled job.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master._assignJob">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="papyros.Master-class.html#_getProcessedJob" class="summary-sig-name">_getProcessedJob</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">job</span>)</span><br />
      Add a processed job in the output queue.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="papyros-pysrc.html#Master._getProcessedJob">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__str__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">input_size</span>=<span class="sig-default">0</span>,
        <span class="sig-arg">output_size</span>=<span class="sig-default">0</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Initialize this master.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>input_size</code></strong> - If a positive integer, it's the maximum number of unassigned 
          jobs. Trying to <a href="papyros.Master-class.html#addJob" 
          class="link">add</a> a new <a href="papyros.Job-class.html" 
          class="link">Job</a> when the queue is full blocks or raises 
          <code>Queue.Full</code> exception.</li>
        <li><strong class="pname"><code>output_size</code></strong> - If a positive integer, it's the maximum number of completed 
          jobs waiting to be fetched. No more jobs are assigned to the 
          slaves when this number is reached.</li>
    </ul></dd>
    <dt>Overrides:
      object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="addJob"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">addJob</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">job</span>,
        <span class="sig-arg">timeout</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master.addJob">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Add a <a href="papyros.Job-class.html" class="link">Job</a> to the 
  input queue.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>timeout</code></strong> - If the input queue is full and <code>timeout is None</code>, 
          block until a slot becomes available. If <code>timeout &gt; 
          0</code>, block for up to <code>timeout</code> seconds and raise 
          <code>Queue.Full</code> exception if the queue is still full. If 
          <code>timeout &lt;= 0</code>, do not block and raise 
          <code>Queue.Full</code> immediately if the queue is full.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="popProcessedJob"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">popProcessedJob</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">timeout</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master.popProcessedJob">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Pop the next processed <a href="papyros.Job-class.html" 
  class="link">Job</a> from the output queue.</p>
  If there are no pending jobs, it returns <code>None</code>. 
  Otherwise:
  <ul>
    <li>
      If <code>timeout is None</code>, block until a job has finished 
      and return it.
    </li>
    <li>
      If <code>timeout &lt;= 0</code>, return the first finished job 
      that is immediately available without blocking, or <code>None</code> 
      otherwise.
    </li>
    <li>
      If <code>timeout &gt; 0</code>, wait up to <code>timeout</code> 
      seconds for a job to finish and return it; return <code>None</code> 
      if no job has finished by the deadline.
    </li>
  </ul>
  <dl class="fields">
    <dt>Returns:</dt>
        <dd>The next processed <a href="papyros.Job-class.html" 
          class="link">Job</a> or <code>None</code> if there is no 
          available for the given <code>timeout</code>.</dd>
  </dl>
</td></tr></table>
</div>
<a name="processedJobs"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">processedJobs</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">timeout</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master.processedJobs">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  Return a list of processed jobs.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>timeout</code></strong> - If <code>timeout is None</code> or <code>timeout &lt;= 
          0</code>, it is equivalent to keep calling <a 
          href="papyros.Master-class.html#popProcessedJob" 
          class="link">popProcessedJob</a> until it returns None. If 
          <code>timeout &gt; 0</code>, this is the maximum overall time to 
          spend on collecting processed jobs.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="_assignJob"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_assignJob</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">poll_time</span>=<span class="sig-default">10</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master._assignJob">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Pop the next unassigned non-cancelled job.</p>
  If there are no assigned jobs, keep polling every 
  <code>poll_time</code> seconds until one comes in. If the job has been 
  cancelled, it is silently discarded. This method should only be called by
  a <a href="papyros.Slave-class.html" class="link">Slave</a> of this 
  master.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="_getProcessedJob"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_getProcessedJob</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">job</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="papyros-pysrc.html#Master._getProcessedJob">source&nbsp;code</a></span>&nbsp;
    </td>
  </table>
  
  <p>Add a processed job in the output queue.</p>
  This method should only be called by a <a 
  href="papyros.Slave-class.html" class="link">Slave</a> of this 
  master.
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="papyros-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >Papyros API documentation</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0beta1 on Sun Jun 10 22:21:42 2007
    </td>
    <td align="right" class="footer">
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie()
  // -->
</script>
  
</body>
</html>
